package com.trkj.service.wdm;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.trkj.dao.wdm.CharacteristicItemDAO;
import com.trkj.dao.wdm.DefinitionDeptDao;
import com.trkj.dao.wdm.DutyDAO;
import com.trkj.dao.wdm.EdubackgroundsDAO;
import com.trkj.dao.wdm.JobStatusDAO;
import com.trkj.dao.wdm.MaritalStatusDAO;
import com.trkj.dao.wdm.MotherTongueDAO;
import com.trkj.dao.wdm.NationalityDAO;
import com.trkj.dao.wdm.ProfessionalTitleDAO;
import com.trkj.dao.wdm.SocialRelationsDAO;
import com.trkj.dao.wdm.StaffInformationDAO;
import com.trkj.pojo.CharacteristicItem;
import com.trkj.pojo.DefinitionDept;
import com.trkj.pojo.Duty;
import com.trkj.pojo.Edubackground;
import com.trkj.pojo.JobStatus;
import com.trkj.pojo.MaritalStatus;
import com.trkj.pojo.MotherTongue;
import com.trkj.pojo.Nationality;
import com.trkj.pojo.Position;
import com.trkj.pojo.ProfessionalTitle;
import com.trkj.pojo.SocialRelation;
import com.trkj.pojo.StaffInformation;
import com.trkj.vo.StaffInformationVO;

@Service
@Transactional(rollbackFor = Exception.class)
public class StaffInformationService {
	@Autowired
	private StaffInformationDAO staffinformationdao;
	
	/**
	 * 分页查询所有
	 * @param page
	 * @param rows
	 * @return
	 */
	public List<StaffInformationVO> queryByPage(int page,int rows){
		List<Object[]> list =staffinformationdao.queryByNamePage(new PageRequest(page-1, rows));
		List<StaffInformationVO> listvo = new ArrayList<>();
		if(list!=null){
			for(Object[] objs:list){
				StaffInformation s =(StaffInformation) objs[0];
				DefinitionDept d =(DefinitionDept) objs[1];
				
				StaffInformationVO staff = new StaffInformationVO();
				staff.setStainId(s.getStainId());
				staff.setStainName(s.getStainName());
				staff.setDefideId(d.getDefideId());
				staff.setDefideName(d.getDefideName());
				
				listvo.add(staff);
				
			}
		}
		return listvo;
	}
	
	
	/**
	 * 获取总记录条数
	 * @return
	 */
	public long queryByPageCount(){
		return staffinformationdao.count();
	}
	
	
	
	/**
	 * 查询所有特征项
	 * @return
	 */
	@Autowired
	private CharacteristicItemDAO characdao;
	public List<CharacteristicItem> AllChar(){
		return (List<CharacteristicItem>) characdao.findAll();
	}
	
	
	/**
	 * 查询所有部门
	 */
	@Autowired
	private DefinitionDeptDao deptDao;
	public List<DefinitionDept> AllDept(){
		return (List<DefinitionDept>) deptDao.findAll();
	}
	
	/**
	 * 查询所有职务
	 */
	@Autowired
	private DutyDAO dutyDao;
	public List<Duty> AllDuty(){
		return  (List<Duty>) dutyDao.findAll();
	}
	
	/**
	 * 查询所有用工状态
	 */
	@Autowired
	private JobStatusDAO jdao;
	public List<JobStatus> AllJobStatus(){
		return  (List<JobStatus>) jdao.findAll();
	}
	
	/**
	 * 查询所有学历
	 */
	@Autowired
	private  EdubackgroundsDAO edudao;
	public List<Edubackground> AllEdubackground(){
		return  (List<Edubackground>) edudao.findAll();
	}
	
	
	/**
	 * 查询所有婚姻状况
	 */
	@Autowired
	private  MaritalStatusDAO mardao;
	public List<MaritalStatus> AllMaritalStatus(){
		return  (List<MaritalStatus>) mardao.findAll();
	}
	
	/**
	 * 查询所有民族
	 */
	@Autowired
	private  NationalityDAO nationdao;
	public List<Nationality> AllNationality(){
		return  (List<Nationality>) nationdao.findAll();
	}
	

	/**
	 * 查询所有母语
	 * @return
	 */
	@Autowired
	private  MotherTongueDAO mdao;
	public List<MotherTongue> AllMotherTongue(){
		return (List<MotherTongue>) mdao.findAll();
	}
	

	/**
	 * 查询所有社会关系
	 * @return
	 */
	@Autowired
	private  SocialRelationsDAO sdao;
	public List<SocialRelation> AllSocialRelation(){
		return (List<SocialRelation>) sdao.findAll();
	}
	
	/**
	 * 查询所有职称
	 */
	@Autowired
	private  ProfessionalTitleDAO prodao;
	public List<ProfessionalTitle> AllProfessionalTitle(){
		return (List<ProfessionalTitle>) prodao.findAll();
	}
	
	
	
	
	
	
	
}
